package com.heartware.sh.blackhole.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.heartware.sh.blackhole.R;
import com.heartware.sh.blackhole.adapter.FiveListAdapter;
import com.heartware.sh.blackhole.entity.test.MySay;
import com.heartware.sh.blackhole.ui.activity.base.BaseActivity;
import com.widget.recyclerview.DividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/7 0007.
 */
public class FiveActivity extends BaseActivity {

    private RecyclerView rv;
    private FiveListAdapter adapter;
    private List<MySay> sayList = new ArrayList<MySay>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getToolBarX().setTitle("仙剑迷");
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_five;
    }

    @Override
    public void initView() {
        super.initView();
        rv = (RecyclerView) findViewById(R.id.rv);

        createData();
        adapter = new FiveListAdapter();
        adapter.setSayList(sayList);

        /** 设置item动画*/
        rv.setItemAnimator(new DefaultItemAnimator());
//        /** 设置item Divider  ListView*/
//        rv.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
        /** 设置Recyclerview显示样式,   类似Listview*/
        RecyclerView.LayoutManager manager = new LinearLayoutManager(mContext);

        rv.setLayoutManager(manager);


        rv.setAdapter(adapter);
    }


    @Override
    public void setListener() {
        super.setListener();

        adapter.setItemClickListener(new FiveListAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                Toast.makeText(mContext, sayList.get(position).getContent(), Toast.LENGTH_SHORT).show();
            }
        });

        adapter.setItemLongClickListener(new FiveListAdapter.MyItemLongClickListener() {
            @Override
            public void onItemLongClick(View v, int position) {
                Toast.makeText(mContext, sayList.get(position).getAuthor(), Toast.LENGTH_SHORT).show();
            }
        });
    }



    public void createData(){

        sayList.add(new MySay("没有值得不值得, 只有愿意不愿意!", "彩依"));
        sayList.add(new MySay("既不回头, 何必不忘. 既然无缘,何须誓言.", "赵灵儿"));
        sayList.add(new MySay("不曾得到, 谈何放下. 既已得到, 又如何放下.", "仙剑奇侠传"));
        sayList.add(new MySay("轮回的是古人, 不变的是初心!", "仙剑奇侠传"));
        sayList.add(new MySay("魔非魔, 道非道, 善恶在人心. 欲非欲, 情非情, 姻缘由天定.","仙剑奇侠传"));
        sayList.add(new MySay("离景似是昨日, 转眼却已千年. 往事依旧, 物是全非", "仙剑奇侠传"));
        sayList.add(new MySay("最痛的伤口, 是从外面看不到的", "刘晋元"));
        sayList.add(new MySay("相爱, 不如相知, 与其执着痴念, 不如化为祝福. ", "刘晋元"));
        sayList.add(new MySay("死何其容易, 只是留下来的人, 才是最痛苦的. 人终有一死, 妖也如此", "仙剑奇侠传"));
        sayList.add(new MySay("你以为每天看到的东西, 就能抓得住吗?", "酒剑仙"));
        sayList.add(new MySay("感情贵在专致, 始终如一", "林天南"));
        sayList.add(new MySay("如果要牺牲的话, 让我来吧.", "仙剑奇侠传"));
        sayList.add(new MySay("君子, 小人, 皆在一念思量", "仙剑奇侠传"));
        sayList.add(new MySay("到家了, 一定要叫醒我, 我怕我醒不过来.", "赵灵儿"));
        sayList.add(new MySay("承君此诺, 必守一生", "慕容紫英"));
        sayList.add(new MySay("一杯愁绪, 几段情缘, 莫过, 与君对酒当歌", "刘晋元"));
        sayList.add(new MySay("好! 吃到老, 玩到老", "林月如"));
        sayList.add(new MySay("郁结憾恨一念泯, 恩怨情仇皆如尘.", "姜明"));
        sayList.add(new MySay("误会往往源于以为了解.", "刘晋元"));
        sayList.add(new MySay("喜欢一个人就要真心对她好, 哪怕她不喜欢你, 甚至不认得你都没有关系.", "云天青"));
        sayList.add(new MySay("相见不如不见, 有情还似无情.", "重楼"));
        sayList.add(new MySay("如果得道就是牺牲所有人来成全自己, 我宁愿执迷不悟.", "酒剑仙"));
        sayList.add(new MySay("无所谓好或不好, 人生一场虚空大梦, 韶华白首, 不过转瞬.", "慕容紫英"));

    }

}
